/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.service.AuthProvider;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public abstract class AdminGalDocumentHandler
/*    */   extends AdminDocumentHandler
/*    */ {
/* 32 */   private static final String[] TARGET_ACCOUNT_PATH = { "galAcctId" };
/*    */   
/*    */   protected String[] getProxiedAccountPath() {
/* 35 */     return TARGET_ACCOUNT_PATH;
/*    */   }
/*    */   
/*    */   protected Element proxyIfNecessary(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/*    */     try
/*    */     {
/* 42 */       ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */       
/* 44 */       Provisioning prov = Provisioning.getInstance();
/*    */       
/*    */ 
/* 47 */       String[] xpath = getProxiedAccountPath();
/* 48 */       String acctId = xpath != null ? getXPath(request, xpath) : null;
/* 49 */       if (acctId != null) {
/* 50 */         Account acct = prov.get(Key.AccountBy.id, acctId, zsc.getAuthToken());
/* 51 */         if (acct != null) {
/* 52 */           if (!Provisioning.onLocalServer(acct))
/*    */           {
/*    */ 
/*    */ 
/* 56 */             boolean proxied = request.getAttributeBool("galAcctProxied", false);
/* 57 */             if (proxied)
/*    */             {
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/* 64 */               return proxyRequest(request, context, AuthProvider.getAdminAuthToken(), acctId);
/*    */             }
/*    */             
/*    */ 
/*    */ 
/* 69 */             Server server = acct.getServer();
/* 70 */             return proxyRequest(request, context, server);
/*    */           }
/*    */           
/*    */ 
/* 74 */           return null;
/*    */         }
/*    */       }
/*    */       
/*    */ 
/*    */ 
/* 80 */       return super.proxyIfNecessary(request, context);
/*    */     }
/*    */     catch (ServiceException e) {
/* 83 */       if ("service.PROXY_ERROR".equals(e.getCode())) {
/* 84 */         return null;
/*    */       }
/*    */       
/* 87 */       throw e;
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/AdminGalDocumentHandler.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */